waitUntil {!(isNull (findDisplay 46))};

//_____________________________________默认名直接失败______________________________
[] execVM "Scripts\badname.sqf";

//_____________________________________绿军人数限制______________________________
if(player call fn_isPlayerRed) then
{
}
else
{
	private _red_num = count (call fn_getPlayerRed);
	private _green_num = count (call fn_getPlayerGreen);
	if(Param_Green * _green_num > _red_num) exitWith
	{
		["End9", false, true, false, true] call BIS_fnc_endMission;
	};
	
	//rating设置，小于-2000为叛徒
	player addRating (((getPlayerScores player) select 5) + ((getPlayerScores player) select 4)) * 1000;

};


//_____________________________________体力设置______________________________
player enableFatigue (Param_Fatigue == 1);
player enableStamina (Param_Fatigue == 1);
player setCustomAimCoef (Param_AimCoef / 100);
player setUnitRecoilCoefficient (Param_AimCoef2 / 100);

//关闭体力，还需消除耐力对晃动的影响
if(Param_Fatigue == 0)then{
	player setUnitTrait ["loadCoef", 0];
};

//_____________________________________收起武器______________________________
//player addAction ["<t color=""#00AEFF"">收起武器</t>", {_unit=_this select 1; _unit action ['SwitchWeapon', _unit, _unit, 100];}, [], 1.5, false]; 

//_____________________________________推______________________________
player addAction ["<t color='#ff8400'>推--></t>","Scripts\Push.sqf", [], -500, false, false, "", "call Push_k1_Check2"];

//_____________________________________取消原版打包______________________________
(findDisplay 46) displayAddEventHandler ["KeyDown", {
	if((_this select 1) == 45
	&& {animationState player in [
	"ainvpknlmstpslaywnondnon_medic",
	"ainvpknlmstpslaywrfldnon_medic",
	"ainvpknlmstpslaywpstdnon_medic"]})then{
		private _damage = damage player;
		//[player,"AmovPknlMstpSnonWnonDnon"]remoteExec["switchMove",0];
		//使用far的函数
		[player, (player call FAR_medic_anim) select 0] remoteExec["switchMove",0];
		
		_damage spawn{sleep 2;player setDamage _this;}//取消后还原血量
}}
];

if(player call fn_isPlayerRed) then
{

	//___________________________________查看上校________________________________
	player addAction [format["<t color=""#fff100"">%1</t>", localize "STR_TAG_A_0"], "functions\fn_showEndPos.sqf", [], 10, false, true, "", "[] call fnc_checkMap"];

	fnc_checkMap = {
		if(isNull cursorTarget) exitwith {false};
		if((player distance cursorTarget)>3) exitwith {false};
		if(typeOf cursorTarget == "MapBoard_altis_F")  exitwith {true};
		false
	};

	//___________________________________查看指挥部________________________________
	player addAction [format["<t color=""#fff100"">%1</t>", localize "STR_TAG_A_1"], "as_show_e5 = true; publicVariable 'as_show_e5'", [], 10, false, true, "", "[] call fnc_checkMap2"];

	fnc_checkMap2 = {
		if(isNull cursorTarget) exitwith {false};
		if((player distance cursorTarget)>3) exitwith {false};
		if(typeOf cursorTarget == "Land_MapBoard_01_Wall_Altis_F")  exitwith {true};
		false
	};

	//___________________________________新玩家专用_______________________________
	//移到了initPlayer
	/*player addAction [format["<t color=""#00ff00"">新手限用</t>", localize "STR_TAG_A_11"], 
	{
		params ["_target", "_caller", "_actionId", "_arguments"];
		player remoteExec ["fnc_newPlayer", 2];
		player removeAction _actionId;
		
	}, [], 10, false, true, "", "player getVariable ['as_play_time',0] < 10"];
	*/
	


	//_____________________________________抢救资源______________________________
	player addAction [format["<t color=""#00ff00"">%1</t>", localize "STR_TAG_A_2"], "_this call fn_searchVeh", [], 8, false, true, "", "[] call fnc_checkPlane"]; 

	fnc_checkPlane = {
		if (isNull cursorTarget || {!alive cursorTarget}) exitwith {false};
		if((player distance cursorTarget)>9) exitwith {false};
		if(typeOf cursorTarget == "O_T_VTOL_02_infantry_dynamicLoadout_F") exitwith {true};
		false
	};
	
	//排行榜
	player addAction [format["<t color='#4169E1'>%1</t>", localize "STR_TAG_A_3"], {call fn_showScore}, [], -1002, false];
	
	//如何胜利（已废弃）
	//player addAction ["<t color='#4169E1'>如何胜利</t>", {call fn_showHowWin}, [], -1002, false];

	//是尸体
	fnc_checkDeath = {
		if (isNull cursorTarget || {alive cursorTarget}) exitwith {false};
		if((player distance cursorTarget)>2) exitwith {false};
		if(cursorTarget getVariable["death_search_ed", false]) exitWith{false};
		if(cursorTarget isKindOf "MAN") exitwith {true};
		false
	};
	//搜刮尸体
	player addAction [format["<t color=""#00ff00"">%1</t><t color=""#d50e0e"">[+10]</t>", localize "STR_TAG_A_8"], 
	{
		cursorTarget setVariable["death_search_ed", true];
		player action ["hideBody", cursorTarget];
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money + 10, true];
	}, [], -904, false, true, "", "[] call fnc_checkDeath"];

	//回收资源
	fnc_checkRes = {
		if (isNull cursorTarget || {(player distance cursorTarget)>4}) exitwith {false};

		private _res_num = cursorTarget getVariable["res_num", 0];
		if(_res_num <= 0) exitWith{false};
		
		player setUserActionText [
		as_player_action_id_res,
		format["<t color=""#00ff00"">回收资源</t><t color=""#d50e0e"">[+%1]</t>",
		_res_num]];
		
		true
	};
	as_player_action_id_res = player addAction ["<t color=""#00ff00"">回收资源</t>", 
	{
		private _res_num = cursorTarget getVariable["res_num", 0];
		if(_res_num > 0) then
		{
			deleteVehicle cursorTarget;
			private _money = player getVariable["as_money", 0];
			player setVariable["as_money",  _money + _res_num, true];
		};
	}, [], -904, false, true, "", "[] call fnc_checkRes"];

	


	//---------------------------------------------------------建造 等---------------------------------------------------------------------------
	as_cb_ing = false;
	(findDisplay 46) displayAddEventHandler ["KeyDown", {if((_this select 1) == 45)then {as_cb_ing = false;}}];
	
	
	//注意：需要在unit.sqf文件763行 添加可建造的物体类名
	//在fn_createVehSimple设置回收价格
	
	//名字、花费金钱数、建造时间、建筑名字
	["建造沙包", 10, 1, "Land_BagFence_End_F"] call fn_addActionB;
	["垒平位置", 15, 3, "ShootingPos_F"] call fn_addActionB;
	["建造掩体", 20, 5, "Land_SandbagBarricade_01_hole_F"] call fn_addActionB;
	["建造架子", 30, 6, "Land_Scaffolding_F"] call fn_addActionB;
	["建造货架", 40, 6, "Truck_01_Rack_F"] call fn_addActionB;
	["建造箱子", 50, 8, "Box_Syndicate_Wps_F"] call fn_addActionB;
	["建造集装箱", 60, 10, "Land_Cargo20_military_green_F"] call fn_addActionB;
	["建造碉堡", 500, 30, "Land_Bunker_01_tall_F"] call fn_addActionB;
	
	
	//------------------------------------------------------------------------------------------------------------------------------------
	//拿起物品
	as_hand_veh = objNull;
	player addAction ["<t color=""#00ff00"">拿起物品</t>", 
	{
		if (isNull cursorTarget || {(player distance cursorTarget)>2}) exitwith {false};
		
		as_hand_veh = cursorTarget;
		detach as_hand_veh;
		as_hand_veh attachTo [player, [0,-0.15,.4], "Pelvis"];
		
		[as_hand_veh, [[1.0, 0, 0], [0, -1.0, 0.2]]] remoteExec ["setVectorDirAndUp",2];
		//[cursorTarget, 90] remoteExec ["setDir",0];
		
	}, [], 1, false, true, "", "cursorTarget getVariable ['as_pickup',false] && {isNull attachedTo cursorTarget}"];
	//放下物品
	player addAction ["<t color=""#ff0000"">放下物品</t>", 
	{
		detach as_hand_veh;
		as_hand_veh = objNull;
	}, [], -1003, false, true, "", "!isNull as_hand_veh"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">运输皮卡</t><t color=""#d50e0e"">[-120]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 120, true];
		[player, "SupportTransport"] call BIS_fnc_addCommMenuItem;
	}, [], -1120, false, true, "", "player getVariable ['as_money',0] >= 120"];
	
	//精准打击
	player addAction ["<t color=""#00ff00"">精准打击</t><t color=""#d50e0e"">[-140]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 140, true];
		[player, "SupportD21"] call BIS_fnc_addCommMenuItem;
	}, [], -1140, false, true, "", "player getVariable ['as_money',0] >= 140"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">空投快艇</t><t color=""#d50e0e"">[-160]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 160, true];
		[player, "SupportBoat"] call BIS_fnc_addCommMenuItem;
	}, [], -1160, false, true, "", "player getVariable ['as_money',0] >= 160"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">发射器箱</t><t color=""#d50e0e"">[-180]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 180, true];
		[player, "SupportLaunch"] call BIS_fnc_addCommMenuItem;
	}, [], -1180, false, true, "", "player getVariable ['as_money',0] >= 180"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">空投燃料</t><t color=""#d50e0e"">[-200]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 200, true];
		[player, "SupportFuel"] call BIS_fnc_addCommMenuItem;
	}, [], -1200, false, true, "", "player getVariable ['as_money',0] >= 200"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">无人机端</t><t color=""#d50e0e"">[-220]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 220, true];
		[player, "SupportUav"] call BIS_fnc_addCommMenuItem;
	}, [], -1220, false, true, "", "player getVariable ['as_money',0] >= 220"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">基本武器</t><t color=""#d50e0e"">[-240]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 240, true];
		[player, "SupportBase"] call BIS_fnc_addCommMenuItem;
	}, [], -1240, false, true, "", "player getVariable ['as_money',0] >= 240"];

	//购买支援
	player addAction ["<t color=""#00ff00"">武装麒麟</t><t color=""#d50e0e"">[-260]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 260, true];
		[player, "SupportQL"] call BIS_fnc_addCommMenuItem;
	}, [], -1260, false, true, "", "player getVariable ['as_money',0] >= 260"];

	//无人机套装
	player addAction ["<t color=""#00ff00"">无人机套装</t><t color=""#d50e0e"">[-280]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 280, true];
		[player, "SupportUavAll"] call BIS_fnc_addCommMenuItem;
	}, [], -1280, false, true, "", "player getVariable ['as_money',0] >= 280"];

	//购买支援
	player addAction ["<t color=""#00ff00"">伊芙雷特</t><t color=""#d50e0e"">[-300]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 300, true];
		[player, "SupportLfrit"] call BIS_fnc_addCommMenuItem;
	}, [], -1300, false, true, "", "player getVariable ['as_money',0] >= 300"];

	//购买支援
	player addAction ["<t color=""#00ff00"">特殊武器</t><t color=""#d50e0e"">[-350]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 350, true];
		[player, "SupportSpecial"] call BIS_fnc_addCommMenuItem;
	}, [], -1350, false, true, "", "player getVariable ['as_money',0] >= 350"];

	//购买支援
	player addAction ["<t color=""#00ff00"">车辆弹药</t><t color=""#d50e0e"">[-400]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 400, true];
		[player, "SupportAmmo"] call BIS_fnc_addCommMenuItem;
	}, [], -1400, false, true, "", "player getVariable ['as_money',0] >= 400"];

	//购买支援
	player addAction ["<t color=""#00ff00"">导弹覆盖</t><t color=""#d50e0e"">[-600]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 600, true];
		[player, "SupportD41"] call BIS_fnc_addCommMenuItem;
	}, [], -1600, false, true, "", "player getVariable ['as_money',0] >= 600"];

	//购买支援
	player addAction ["<t color=""#00ff00"">报废坦克</t><t color=""#d50e0e"">[-700]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 700, true];
		[player, "SupportTank"] call BIS_fnc_addCommMenuItem;
	}, [], -1700, false, true, "", "player getVariable ['as_money',0] >= 700"];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">固定翼</t><t color=""#d50e0e"">[-800]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 800, true];
		[player, "Support199"] call BIS_fnc_addCommMenuItem;
	}, [], -1800, false, true, "", "player getVariable ['as_money',0] >= 800"];

	//金钱放地上
	player addAction [format["<t color='#ff8400'>%1</t>", localize "STR_TAG_A_9"],
	{
		//马上扣钱
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 100, true];
		
		
		[player, 100] remoteExec ["fn_putMoney", 2];
	}, [], -2000, false, false, "", "player getVariable ['as_money',0] > 99"];
/*
	//_____________________________________接手控制______________________________
	player addAction ["<t color=""#00ff00"">接手控制</t>", 
	{
		player action ["TakeVehicleControl", vehicle player];
	}, [], 10, true, true, "", "[] call fnc_checkTakeVeh"]; 

	fnc_checkTakeVeh = {
		private _veh = vehicle player;
		if(_veh == player) exitwith {false};
		private _driver = driver _veh;
		if(_driver == objNull) exitwith {false};
		if(_driver getVariable ['FAR_isUnconscious',0] == 1) exitwith {true};
		false
	};
*/
	
	player addAction ["<t color=""#38e987"">上车 </t>", 
	{
		private _in = true;
		{//是ai或者绿军玩家 就不能上车
			if(alive _x && {!isPlayer _x || side _x == resistance}) exitWith{_in = false};
		}forEach (crew cursorTarget);
		if(_in) then{player moveInAny cursorTarget};
	}, [], -901, false, true, "", "[] call fnc_checkVeh"];
}
else
{
	
	//搜刮 改为红军死亡玩家掉落一半金钱
	/*
	fnc_checkSerach = {
		if (isNull cursorTarget 
		|| {(player distance cursorTarget)>4}
		|| {!isPlayer cursorTarget}
		|| {!(cursorTarget call fn_isPlayerRed)}) exitwith {false};
		true
	};
	player addAction ["<t color='#ff8400'>搜刮金钱</t>",
	{
		private _t = cursorTarget getVariable["as_s_time", -1];
		//防止短时间重复操作
		if(_t >= 0 && {time < _t + 300}) exitWith{};
		
		cursorTarget setVariable["as_s_time", time, true];
		//扣钱（只扣一半）
		private _money_this = player getVariable["as_money", 0];
		private _money_target = cursorTarget getVariable["as_money", 0];
		
		cursorTarget setVariable["as_money",  _money_target * 0.5, true];
		player setVariable["as_money",  _money_this + _money_target * 0.5, true];

 		[player, format ["从 %1身上抢走了金钱：%2。", name cursorTarget, _money_target * 0.5]] remoteExec ["globalChat", 0];
		
	}, [], 1000, false, false, "", "[] call fnc_checkSerach"];
	*/
	
	//传送
	player addAction ["<t color=""#00ff00"">传送到红军玩家附近</t>", 
	{
		private _list = call fn_getPlayerRed;
		private _player_other = objNull;
		if(count _list > 0) then
		{_player_other = selectRandom _list};

		if(!isNull _player_other) then
		{
			private _pos = [getPos _player_other, 1000, 200] call fn_getPosNearLand;
			["I_G_Quadbike_01_F", _pos, 0]remoteExec["fn_createVehSimple",2];
			player setVehiclePosition [_pos, [], 0, "NONE"];
		};
	}, [], 100, false, true, "", "player distance2D getMarkerPos 'mk_players' < 500"];
	
	//传送
	player addAction ["<t color=""#00ff00"">传送到队友附近</t>", 
	{
		private _list = units group player;
		private _player_other = objNull;
		if(count _list > 0) then
		{_player_other = selectRandom _list};

		if(!isNull _player_other) then
		{
			if(vehicle _player_other != _player_other) then{
				player moveInAny (vehicle _player_other);
			}else{
				player setVehiclePosition [getPos _player_other, [], 0, "NONE"];
			};
		};
	}, [], 99, false, true, "", "player distance2D getMarkerPos 'mk_players' < 500"];
	
	//夜视仪
	player addItem "NVGoggles";
	player assignItem "NVGoggles";
	
	//
	player addAction ["<t color=""#38e987"">上车 </t>", 
	{
		private _in = true;
		{//是红军 就不能上车
			if(alive _x && {side _x == east}) exitWith{_in = false};
		}forEach (crew cursorTarget);
		if(_in) then{player moveInAny cursorTarget};
	}, [], -901, false, true, "", "[] call fnc_checkVeh"];
	
	//限制使用补给
	//player addEventHandler ["Take", {
	//params ["_unit", "_container", "_item"];
	//	if(type _container == "CargoNet_01_box_F") then
	//	{
	//		[resistance, "军官", "公共财产，禁止挪用！"] remoteExec ["fn_talk", _unit];
	//	};
	//}];
	
	//购买支援
	player addAction ["<t color=""#00ff00"">空投越野</t><t color=""#d50e0e"">[-70]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 70, true];
		[player, "SupportJQYY"] call BIS_fnc_addCommMenuItem;
	}, [], -1070, false, true, "", "player getVariable ['as_money',0] > 69"];
	
	
	//消购买战绩
	player addAction ["<t color=""#00ff00"">归零战绩</t><t color=""#d50e0e"">[-100]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 100, true];
		[player, -((getPlayerScores player) select 5) + ((getPlayerScores player) select 4)] remoteExec ["addScore", 2];
		player addRating (-rating player);
	}, [], -1100, false, true, "", "(player getVariable ['as_money',0] >= 100) && {rating player < 0}"];
	
	//购买Hunter
	player addAction ["<t color=""#00ff00"">空投Hunter</t><t color=""#d50e0e"">[-160]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 160, true];
		[player, "SupportHunter"] call BIS_fnc_addCommMenuItem;
	}, [], -1160, false, true, "", "player getVariable ['as_money',0] > 159"];
	
	//皮卡支援
	player addAction ["<t color=""#00ff00"">皮卡支援</t><t color=""#d50e0e"">[-300]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 300, true];
		[player, "SupportPK"] call BIS_fnc_addCommMenuItem;
	}, [], -1300, false, true, "", "player getVariable ['as_money',0] > 299"];
	
	//购买迫击炮
	player addAction ["<t color=""#00ff00"">空投迫击炮</t><t color=""#d50e0e"">[-500]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 500, true];
		[player, "SupportPJP"] call BIS_fnc_addCommMenuItem;
	}, [], -1500, false, true, "", "player getVariable ['as_money',0] > 499"];
	
	//武直支援
	player addAction ["<t color=""#00ff00"">武直支援</t><t color=""#d50e0e"">[-800]</t>", 
	{
		private _money = player getVariable["as_money", 0];
		player setVariable["as_money",  _money - 800, true];
		[player, "SupportAH99"] call BIS_fnc_addCommMenuItem;
	}, [], -1900, false, true, "", "player getVariable ['as_money',0] > 799"];
	
	//重生
	player addAction ["<t color=""#ff0000"">自杀</t>", 
	{
		player setDamage 1;
	}, [], -3000, false, true, "", "true"];
};


//---------------------------------------------------------双枪---------------------------------------------------------------------------
call fn_doubleWeapon;

//___________________________________修复筒子不能锁定________________________________
player addAction ["<t color=""#fff100"">修复火箭筒不能锁定</t>", {
	player remoteExec ["fnc_dropLaunch", 2];
}, [], -906, false, true, "", "secondaryWeapon player != '' && {currentWeapon player == secondaryWeapon player}"];

//___________________________________成为队长________________________________
player addAction ["<t color=""#fff100"">成为队长</t>", {
	[group player, player] remoteExec ["selectLeader", groupOwner group player];
}, [], -999, false, true, "", "(player getVariable['as_win', 0]) > ((leader group player) getVariable['as_win', 999])"];

//除草
//---------------------------------------------------------除草---------------------------------------------------------------------------
player addAction [
	format["<t color='#38e987'>%1</t>", localize "STR_TAG_A_4"],
	{
		createVehicle ["Land_ClutterCutter_medium_F",player getPos [2.5, getDir player],[],0,"CAN_COLLIDE"];
	},
	[],
	-905,
	false,
	true,
	"",
	"alive _target"
];


//___________________________________扶起倒地________________________________
player addAction [format["<t color=""#fff100"">%1</t>", localize "STR_TAG_A_5"], {
	[cursorTarget]spawn{
		[player,'AinvPknlMstpSlayWrflDnon_medicOther'] remoteExec['playMoveNow',0];
		Sleep 6;
		[_this select 0, false] remoteExec ["setUnconscious", 0];
	};
}, [], 10, false, true, "", "[] call fnc_checkDown"];

fnc_checkDown = {
	if(isNull cursorTarget || {isPlayer cursorTarget}) exitwith {false};
	if((player distance cursorTarget)>3) exitwith {false};
	if(lifeState cursorTarget == "INCAPACITATED")  exitwith {true};
	false
};


//dlc
fnc_checkObject = {
	if(isNull cursorTarget) exitwith {false};
	if((player distance cursorTarget)>3) exitwith {false};
	true
};


fnc_checkVeh = {
	if(isNull cursorTarget || {!alive cursorTarget}) exitwith {false};
	if((player distance cursorTarget)>8) exitwith {false};
	if(cursorTarget isKindOf "Car" || {cursorTarget isKindOf "Tank"} || {cursorTarget isKindOf "Air"}) exitwith{true};
	false
};

fnc_checkUAV = {
	if(isNull cursorTarget || {!alive cursorTarget}) exitwith {false};
	if((player distance cursorTarget)>8) exitwith {false};
	if(unitIsUAV cursorTarget) exitwith{true};
	false
};

//自己是司机
fnc_checkDriver = {
	if(vehicle player == player) exitwith {false};
	if(driver vehicle player != player) exitwith {false};
	true
};

//_____________________________________dlc操作______________________________
fnc_player_dlc_close = {
	player removeAction as_player_action_id_open;
	player addAction ["<t color=""#38e987"">关闭操作 </t><t color=""#d50e0e""></t>",
	{
		player removeAction (_this select 2);
		player removeAction as_player_action_id_0;
		player removeAction as_player_action_id_1;
		player removeAction as_player_action_id_2;
		player removeAction as_player_action_id_3;
		player removeAction as_player_action_id_4;
		call fnc_player_dlc_weapon_clear;
		call fnc_player_dlc_open;
	}, [], -999, false, true, "", "true"];
};

as_player_dlc_weapon = [];//id, type, name

fnc_player_dlc_weapon_clear =
{
	//清除旧动作
	{
		player removeAction (_x select 0);
	}forEach as_player_dlc_weapon;
	as_player_dlc_weapon = [];
};

fnc_player_dlc_add = {
player addAction [format["<t color='#38e987'>捡起 </t><t color='#d50e0e'>[%1]</t>", _this call fn_getWeaponName],
	{
		{
			//是自己
			if(_x select 0 == _this select 2) exitWith
			{
				player action ["TakeWeapon", cursorTarget, _x select 1];
				player removeAction (_this select 2);
			};
		}forEach as_player_dlc_weapon;
	}, [], -951, false, true, "", "[] call fnc_checkObject"]
					
};

fnc_player_dlc_open = {
	as_player_action_id_open = player addAction ["<t color=""#38e987"">打开操作 </t><t color=""#d50e0e""></t>",
	{
		//___________________________________无DLC捡枪________________________________
		as_player_action_id_0 = player addAction ["<t color=""#38e987"">刷新列表 </t><t color=""#d50e0e""></t>", 
		{
			//获取所有武器名
			private _cargo = (weaponsItemsCargo cursorTarget);
			if(count _cargo == 0) exitWith{};
			
			call fnc_player_dlc_weapon_clear;
			
			{
				as_player_dlc_weapon pushBack [(_x select 0)call fnc_player_dlc_add, _x select 0];
			}forEach _cargo;
			
		}, [], -950, false, true, "", "[] call fnc_checkObject"];
		
		//___________________________________无DLC上车________________________________
		as_player_action_id_1 = player addAction ["<t color=""#38e987"">上车 </t><t color=""#d50e0e"">[司机]</t>","player moveInDriver cursorTarget", [], -888, false, true, "", "[] call fnc_checkVeh"];
		 
		as_player_action_id_2 = player addAction ["<t color=""#38e987"">上车 </t><t color=""#d50e0e"">[炮手]</t>", 
		{
			private _driver = driver cursorTarget;
			if(isNull _driver) exitwith{player moveInGunner cursorTarget};
			if(side _driver == side player) exitwith{player moveInGunner cursorTarget};
		}, [], -889, false, true, "", "[] call fnc_checkVeh"];

		as_player_action_id_3 = player addAction ["<t color=""#38e987"">上车 </t><t color=""#d50e0e"">[指挥官]</t>", 
		{
			private _driver = driver cursorTarget;
			if(isNull _driver) exitwith{player moveInCommander cursorTarget};
			if(side _driver == side player) exitwith{player moveInCommander cursorTarget};
		}, [], -890, false, true, "", "[] call fnc_checkVeh"];
			
		//___________________________________无DLC连接UAV________________________________
		as_player_action_id_4 = player addAction ["<t color=""#38e987"">连接 </t><t color=""#d50e0e"">[无人机]</t>", 
		{
			player connectTerminalToUAV cursorTarget;
		}, [], -891, false, true, "", "[] call fnc_checkUAV"];
		
		call fnc_player_dlc_close;
	}, [], -997, false, true, "", "true"];
};
if(Param_Version >= 187) then
{
	call fnc_player_dlc_open;
};

player addAction ["<t color=""#00ff00"">请君上车 </t>", 
{
	{
		if(isPlayer _x
		&& {alive _x}
		&& {_x call fn_isPlayerRed}
		&& {(_x getVariable ["FAR_isUnconscious", 1]) == 0}) then
		{
			_x moveInAny vehicle player;
		};
	}forEach ((vehicle player) nearObjects 5);
}, [], -998, false, true, "", "[] call fnc_checkDriver"];

//crew返回的死亡单位有问题
player addAction ["<t color=""#ff0000"">请君下车 </t>", 
{
	{
		if(_x != player) then
		{
			moveOut _x;
		};
	}forEach (crew vehicle player);
}, [], -999, false, true, "", "[] call fnc_checkDriver"];


//___________________________________自爆________________________________
player addAction [format["<t color=""#d50e0e"">%1</t><t color=""#fff100""></t>", localize "STR_TAG_A_6"], 
{
	private _unit= _this select 1;
	if("SatchelCharge_Remote_Mag" in (magazines _unit)) then
	{
		[_unit] spawn fn_bomber;
	};
}, [], -1000, false, true, "", ""];

//___________________________________驾驶员也能弹射________________________________
player addAction ["<t color=""#d50e0e"">跳伞<img image ='\a3\ui_f\data\gui\cfg\CommunicationMenu\supplydrop_ca.paa'/> " ,"player spawn fn_para",nil,-906,false,true,"",
'((vehicle player != player) && {(position player select 2) > 75} && {vehicle player isKindOf "Air"})'
];

//_____________________________ 载具锁定 _____________________________
call fn_lockVeh;

//____________________________________脱光________________________________
if(player call fn_isPlayerRed) then
{

	[player] call fn_clearUnit;

	//个性化
	[player] call fn_initPlayer;

	//传送
	[player] call fn_tpPlayer;

	//臂章
	[player, ""] call BIS_fnc_setUnitInsignia;
	[player, "PLA"] call BIS_fnc_setUnitInsignia;
}
else
{
	//传送
	[player] call fn_tpPlayerGreen;
};
//////////////////////////////////////////////////////////////////////////
//START EARPLUGS CODE

waitUntil {vehicle player == player};
waituntil {!isnull (finddisplay 46)};

//////////////////////////////////////////////////////////////////////////
		_OPRbreathing = alive player;
		_OPRtrig=true;
		_OPRdude = player;

			while {_OPRtrig} do {

				sleep 0.001;

					if (_OPRbreathing) then {
						_OPRstartingpos = position player;
						sleep 0.001;
						_OPRposition = position _OPRdude;

						_OPRstationary = _OPRstartingpos select 0 == _OPRposition select 0 && _OPRstartingpos select 1 == _OPRposition select 1;

						if (_OPRstationary) then {} else {_OPRtrig=false;};
						
					};
			};

uisleep 1;

if (isNil {player getVariable "Has_EPEH_Loop"}) then {player setVariable["Has_EPEH_Loop", "NEVER"];};

//////////////////////////////////////////////////////////////////////////
5 fadeSound 1;
earplugsout=true;	
SuperFunEPEHVariable = false;
/////////////////////////////////////////////////////////////////////////
uisleep 1;
_hasEPEH = player getVariable "Has_EPEH_Loop";
uisleep 1;
if ((_hasEPEH == "NEVER")) then {[] spawn cm_EP_LOOP;};	

if (cmEarplugsKeyPressEnabled) then {
	[] spawn {cmKeyPress = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == cmEarplugs_hotkeyDIKCodeNumber) then {[] call cm_Earplugs_FUNc;};"];};
};
//cmEARPLUGS CODE END



